<%--
    Document   : main
    Created on : 29-set-2010, 14.03.55
    Author     : erola
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Negozio</title>
        <link rel="stylesheet" type="text/css" href="css/style.css"/>
        <base target="_self"/>
    </head>
    <body>
        <%@include file="WEB-INF/jspf/header.jspf"%>
        <!-- start page -->
        <div id="content">
            <div class="post" style="background: url(images/star.png) no-repeat top right">
                <h2 class="title">Negozio</h2>
                <div class="entry">
                    <c:if test="${requestScope.msg != null}">
                        <div class="msg">
                            ${msg}
                        </div>
                    </c:if>
                    <c:if test="${requestScope.err != null}">
                        <div class="error">
                            ${err}
                        </div>
                    </c:if>
                    <c:choose>
                        <c:when test="${requestScope.lista != null}">
                            <p>Aggiungi prodotti al tuo carrello.</p>
                            <c:forEach var="item" items="${requestScope.lista}">

                                <table width="100%">
                                    <tr id="even">
                                        <th width="40%"><h2>${item.nome}</h2></th>
                                        <th width="40%">Descrizione</th>
                                        <th width="20%">Prezzo</th>
                                    </tr>
                                    <tr id="odd">
                                        <td style="text-align: center"><img src="prod/${item.codice}.png" alt="" /></td>
                                        <td>${item.descrizione}</td>
                                        <td align="center">
                                            <p>${item.prezzo}0 €</p>
                                            <c:if test="${!empty sessionScope.username}">
                                                <form action="CartHandler" method="post">
                                                    <input type="hidden" name="action" value="aggiungi">
                                                    <input type="hidden" name="item" value="${item.id}"/>
                                                    <input type="submit" value="aggiungi al carrello"/>
                                                </form>
                                            </c:if>
                                        </td>
                                    </tr>
                                </table>
                            </c:forEach>

                        </c:when>
                        <c:otherwise>
                            <p>Il negozio è vuoto.</p>
                        </c:otherwise>
                    </c:choose>
                </div>
            </div>
        </div>

        <%@include file="WEB-INF/jspf/nav.jspf"%>
        <!-- end page -->

        <%@include file="WEB-INF/jspf/footer.jspf"%>
    </body>
</html>